﻿<UserControl x:Class="XAMLStylePad.Views.ObjectProvider"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:viewmodel="clr-namespace:XAMLStylePad.ViewModels"
             xmlns:view="clr-namespace:XAMLStylePad.Views"
             xmlns:wpf="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
             x:Name="thisObjectProvider"
             Opacity="1">
    
    <!--Height="100" Width="200"-->
    
    <Border BorderThickness="1" BorderBrush="Black">
        <Grid Margin="5" Name="grid">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="*"/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <TextBlock x:Name="txErrorReport" Grid.Row="0" Foreground="Red">
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <Trigger Property="Text" Value="">
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
            
            <StackPanel Grid.Row="1" Margin="2" Orientation="Vertical">
                <Expander Header="Constructor" IsExpanded="{Binding Path=IsCtorsVisible, Mode=OneTime}">
                    <StackPanel>
                        <ComboBox Grid.Row="0" Name="cmConstructors" 
                                  Margin="0,0,0,15"
                                  ItemsSource="{Binding Path=Constructors}"
                                  SelectedValue="{Binding SelectedConstructor}">
                            
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding DisplayName}"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <ItemsControl DataContext="{Binding ElementName=cmConstructors, Path=SelectedValue}" 
                                      ItemsSource="{Binding Parameters}"
                                      ItemTemplateSelector="{x:Static view:ObjectProvider.Selector}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Vertical">
                                        <StackPanel.Resources>
                                            <ResourceDictionary Source="/Themes/ObjectProviderResources.xaml"/>
                                        </StackPanel.Resources>
                                    </StackPanel>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>
                    </StackPanel>
                </Expander>

                <Expander Header="Fields and Parameters" IsExpanded="{Binding Path=IsMembersVisible, Mode=OneTime}">
                    <StackPanel Orientation="Vertical">
                        <ItemsControl ItemsSource="{Binding Properties}"
                                  ItemTemplateSelector="{x:Static view:ObjectProvider.Selector}">

                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Vertical">
                                        <StackPanel.Resources>
                                            <ResourceDictionary Source="/Themes/ObjectProviderResources.xaml"/>
                                        </StackPanel.Resources>
                                    </StackPanel>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>

                        <ItemsControl ItemsSource="{Binding Fields}"
                                  ItemTemplateSelector="{x:Static view:ObjectProvider.Selector}">

                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Vertical">
                                        <StackPanel.Resources>
                                            <ResourceDictionary Source="/Themes/ObjectProviderResources.xaml"/>
                                        </StackPanel.Resources>
                                    </StackPanel>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>
                    </StackPanel>

                </Expander>
            </StackPanel>
            
            <StackPanel Grid.Row="2" Visibility="{Binding ElementName=thisObjectProvider, Path=CreateButtonVisibility}">
                <Button Width="50px" HorizontalAlignment="Right" BorderBrush="Black" BorderThickness="1" 
                        Margin="0,15,0,0"
                        Name="butGenerate"
                        Click="butGenerate_Click">
                    Create
                </Button>
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
